home *** CD-ROM | disk | FTP | other *** search
- /* real simple test program for the name plug-in attribute */
-
- #define TEST_RADAR_ID_1401065 1
-
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
-
- #include <CodeFragments.h>
- #include <Dialogs.h>
- #include <Fonts.h>
- #include <Memory.h>
- #include <QuickDraw.h>
- #include <StandardFile.h>
- #include <Windows.h>
-
- #include "QD3D.h"
- #include "QD3DExtension.h"
- #include "QD3DGeometry.h"
- #include "QD3DGroup.h"
- #include "QD3DIO.h"
- #include "QD3DMath.h"
- #include "QD3DStorage.h"
-
-
- #include "NameAttribute.h"
-
- static void InitToolbox(void) ;
-
-
-
- /* initialize the Mac toolbox */
- static void InitToolbox(void)
- {
-
- MaxApplZone() ;
- MoreMasters() ; MoreMasters() ; MoreMasters() ;
-
- InitGraf( &qd.thePort );
- InitFonts();
- InitWindows();
-
- FlushEvents( everyEvent, 0 ) ;
-
- InitCursor();
- }
-
-
- static TQ3GroupObject BuildTriangle(
- void)
- {
- TQ3ColorRGB triangleColor;
-
- TQ3GroupObject model;
- TQ3TriangleData triangleData;
- TQ3GeometryObject triangleThang;
- static TQ3Vertex3D vertices[3] = {
- { { -1.0, -0.5, -0.25 }, NULL },
- { { 0.0, 0.0, 0.0 }, NULL },
- { { -0.5, 1.5, 0.45 }, NULL },
- };
-
- triangleData.vertices[0] = vertices[0];
- triangleData.vertices[1] = vertices[1];
- triangleData.vertices[2] = vertices[2];
-
- triangleData.triangleAttributeSet = Q3AttributeSet_New();
- triangleColor.r = 0.8;
- triangleColor.g = 0.5;
- triangleColor.b = 0.2;
-
- Q3AttributeSet_Add(
- triangleData.triangleAttributeSet,
- kQ3AttributeTypeDiffuseColor,
- &triangleColor);
-
- triangleData.vertices[0].attributeSet = Q3AttributeSet_New();
- triangleData.vertices[1].attributeSet = Q3AttributeSet_New();
- triangleData.vertices[2].attributeSet = Q3AttributeSet_New();
- triangleColor.r = 1.0;
- triangleColor.g = 0.0;
- triangleColor.b = 0.0;
-
- Q3AttributeSet_Add(
- triangleData.vertices[0].attributeSet,
- kQ3AttributeTypeDiffuseColor,
- &triangleColor);
-
- triangleColor.r = 0.0;
- triangleColor.g = 1.0;
- triangleColor.b = 0.0;
-
- Q3AttributeSet_Add(
- triangleData.vertices[1].attributeSet,
- kQ3AttributeTypeDiffuseColor,
- &triangleColor);
-
- triangleColor.r = 0.0;
- triangleColor.g = 0.0;
- triangleColor.b = 1.0;
-
- Q3AttributeSet_Add(
- triangleData.vertices[2].attributeSet,
- kQ3AttributeTypeDiffuseColor,
- &triangleColor);
-
- triangleThang = Q3Triangle_New(&triangleData);
-
- model = Q3OrderedDisplayGroup_New();
-
- if (triangleThang != NULL) {
- Q3Group_AddObject(model, triangleThang);
-
- Q3Object_Dispose(triangleThang);
- }
-
- Q3Object_Dispose(triangleData.vertices[0].attributeSet);
- Q3Object_Dispose(triangleData.vertices[1].attributeSet);
- Q3Object_Dispose(triangleData.vertices[2].attributeSet);
- Q3Object_Dispose(triangleData.triangleAttributeSet);
-
- return (model);
- }
-
-
- /* entry point */
- void main(void)
- {
- TQ3Status myStatus ;
- TQ3GroupObject myGroup ;
- const short length = 256 ;
- char myName[ length ] ;
- char *tempStr ;
- const char defaultName[] = "This is the name attribute string" ;
- short index = 0 ;
-
- InitToolbox() ;
- if( (long)Q3Initialize != kUnresolvedCFragSymbolAddress )
- {
- printf( "Initializing QuickDraw 3D" ) ;
-
- if((myStatus = Q3Initialize()) == kQ3Success)
- {
- printf(" - successful\n" ) ;
-
- printf( "Making a test geometry" ) ;
-
- /* make a geometry object */
- if((myGroup = BuildTriangle()) != NULL)
- {
- TQ3XObjectClassVersion myVersion ;
- TQ3ObjectType objectClassType ;
- printf(" - successful\n" ) ;
-
- /* try adding a name to it */
- strcpy( myName, defaultName ) ;
- printf( "Adding String \"%s\" as name attribute to the group\n", myName ) ;
- NameAttribute_SetName( myGroup, myName ) ;
-
- /* zero out the string */
- for( index = 0; index < length; index++ )
- myName[ index ] = '\0' ;
- printf( "Zeroed String \"%s\"\n", myName ) ;
-
- NameAttribute_GetName( myGroup, myName ) ;
- printf( "Got String \"%s\" from name attribute in the group\n", myName ) ;
-
- NameAttribute_GetName( myGroup, myName ) ;
- printf( "Got String \"%s\" from name attribute in the group\n", myName ) ;
-
- NameAttribute_GetName( myGroup, myName ) ;
- printf( "Got String \"%s\" from name attribute in the group\n", myName ) ;
-
- #ifdef FORCE_TO_FAIL_TEST
- /*
- * You can't do this. When the element type is registered QD3D
- * modifies it and passes back a reference. If you want to get
- * the version number for a attribute or element, get the type
- * from the name and then use that type to get the version. This
- * is illustrated below.
- */
- Q3XObjectHierarchy_GetClassVersion kElementTypeName, &myVersion ) ;
- #else
- Q3ObjectHierarchy_GetTypeFromString(kElementTypeNameString, &objectClassType );
- Q3XObjectHierarchy_GetClassVersion( objectClassType, &myVersion ) ;
- #endif
-
- printf( "This is version %d.%d\n",
- Q3_OBJECT_CLASS_GET_MAJOR_VERSION( myVersion ),
- Q3_OBJECT_CLASS_GET_MINOR_VERSION( myVersion ) );
- Q3Object_Dispose( myGroup ) ;
-
- #ifdef TEST_RADAR_ID_1401065
- if( NameAttribute_Unregister() == kQ3Failure )
- printf("NameAttribute_Unregister failed\n") ;
- #endif
- }
- else
- {
- printf(" - failed\n" ) ;
- }
- }
- else
- {
- printf(" - failed\n" ) ;
- }
-
- }
- }
-